
package com.mengmeizi.adapter;


import com.mengmeizi.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckedTextView;

public class TimeSelectorAdapter extends BaseAdapter {

    private String[] times;

    private LayoutInflater inflater;

    public TimeSelectorAdapter(Context context) {
        inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        times = context.getResources().getStringArray(R.array.entries_list_preference);
    }

    @Override
    public int getCount() {
        return times.length;
    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return times[position];
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.item_timelist, null);
        }

        ((CheckedTextView) convertView.findViewById(R.id.ctvTimeItem)).setText(times[position]);

        return convertView;
    }
}
